clear all

********************************************************************************
********************************************************************************
**** When Can We Trust Regression Discontinuity Design Estimates from Close ****
*************** Elections? Evidence from Experimental Benchmarks ***************
********************************************************************************
********************************************************************************

* This file produces Table OA10 in Online Appendix C of De Magalhaes et al. 
* (Political Analysis).

cd "$dir"
use "$dir/data/personal_incumbency_advantage.dta", clear

********************************************************************************

est clear

eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Brazil", c(0) p(1) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(mserd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "MSE"
estadd local polynomial "Linear"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Brazil", c(0) p(2) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(mserd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "MSE"
estadd local polynomial "Quadratic"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Brazil", c(0) p(1) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(cerrd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "CER"
estadd local polynomial "Linear"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Brazil", c(0) p(2) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(cerrd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "CER"
estadd local polynomial "Quadratic"

esttab est* using "$dir/tables/table_OA10.tex", booktabs ///
keep(Conventional Robust) nomtitles ///
replace  nonotes ///
ci(%9.3f) b(%9.3f) stats(N_obs h_l, fmt(0 2)  layout(@) ///
labels("\textit{N}" "Bandwidth")) collabels(none) ///
label nostar	eqlabels(none) ///
prehead(\begin{tabular}{l*{5}{c}} \toprule) ///
postfoot("") refcat(Conventional "\textbf{Panel A:} Brazil", nolabel)

est clear

eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Colombia", c(0) p(1) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(mserd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "MSE"
estadd local polynomial "Linear"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Colombia", c(0) p(2) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(mserd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "MSE"
estadd local polynomial "Quadratic"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Colombia", c(0) p(1) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(cerrd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "CER"
estadd local polynomial "Linear"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Colombia", c(0) p(2) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(cerrd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "CER"
estadd local polynomial "Quadratic"

esttab est* using "$dir/tables/table_OA10.tex", booktabs ///
keep(Conventional Robust) nomtitles nonumbers ///
append  nonotes ///
ci(%9.3f) b(%9.3f) stats(N_obs h_l, fmt(0 2)  layout(@) ///
labels("\textit{N}" "Bandwidth")) collabels(none) ///
label nostar	eqlabels(none) ///
prehead("") ///
postfoot("")	refcat(Conventional "\textbf{Panel B:} Colombia", nolabel)

est clear

eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Denmark", c(0) p(1) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(mserd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "MSE"
estadd local polynomial "Linear"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Denmark", c(0) p(2) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(mserd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "MSE"
estadd local polynomial "Quadratic"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Denmark", c(0) p(1) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(cerrd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "CER"
estadd local polynomial "Linear"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Denmark", c(0) p(2) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(cerrd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "CER"
estadd local polynomial "Quadratic"

esttab est* using "$dir/tables/table_OA10.tex", booktabs ///
keep(Conventional Robust) nomtitles nonumbers ///
append  nonotes ///
ci(%9.3f) b(%9.3f) stats(N_obs h_l, fmt(0 2)  layout(@) ///
labels("\textit{N}" "Bandwidth")) collabels(none) ///
label nostar	eqlabels(none) ///
prehead("") ///
postfoot("")	refcat(Conventional "\textbf{Panel C:} Denmark", nolabel)

est clear

eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Finland", c(0) p(1) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(mserd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "MSE"
estadd local polynomial "Linear"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Finland", c(0) p(2) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(mserd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "MSE"
estadd local polynomial "Quadratic"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Finland", c(0) p(1) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(cerrd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "CER"
estadd local polynomial "Linear"
eststo: rdrobust electednextelection rv if rv!=0 & rv!=. & country=="Finland", c(0) p(2) all rho(1) vce(cluster constituency) kernel(uniform) covs(incumbent) bwselect(cerrd)
scalar bw1 =  e(h_l)
scalar bw2 =  e(b_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw1
estadd scalar bw2
estadd local bandwidth "CER"
estadd local polynomial "Quadratic"

esttab est* using "$dir/tables/table_OA10.tex", booktabs ///
keep(Conventional Robust) nomtitles nonumbers ///
append  nonotes ///
ci(%9.3f) b(%9.3f) stats(N_obs h_l bandwidth polynomial, fmt(0 2)  layout(@) ///
labels("\textit{N}" "Bandwidth" "Bandwidth selector" "Polynomial")) collabels(none) ///
label nostar	eqlabels(none) ///
prehead("") ///
postfoot(\bottomrule \end{tabular})	refcat(Conventional "\textbf{Panel D:} Finland", nolabel)

est clear
